<template>
  <div>

    <el-form  label-position="right"  ref="queryForm" :inline="true" :model="query" label-width="80px" class="demo-form-inline">
      <el-form-item label="角色名称">
        <el-input v-model="query.name" placeholder="角色名称"></el-input>
      </el-form-item>
    </el-form>

    <div >
      <el-button  @click="emitGetRecords" type="primary" class="filter-item">查询</el-button>
      <el-button  @click="emitGetRecords" type="danger" class="filter-item">刷新</el-button>
      <slot></slot>
      <el-button :disabled="selectId.length<=0"  @click="handleDelete" type="primary" class="filter-item">删除</el-button>
    </div>

  </div>
</template>

<script>

import {getToken} from "@/utils/auth";

export default {
  name: "QueryRole",
  props:{
    selectId: {type:Array,default:[]},
    isShowExport: {type:Boolean,default:false},
    isShowUpload: {type:Boolean,default:false},
  },
  data() {
    return {
      query: {
        name: '',
      }
    }
  },
  methods: {

    emitGetRecords() {
      this.$emit('queryRecords', this.query)
    },
    reload() {
      this.$refs['queryForm'].resetFields();
      this.$emit('reloadRecords')
    },
    handleDelete() {
      if (this.selectId.length <= 0) {
        this.$message.error('请先选择项目！')
        return;
      }
      this.$confirm('确定要删除吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const id = this.selectId
        this.$myHttpGet(this.$myUrl.rbac.role.del, {id}).then(res => {
          if (res.status) {
            this.$message.success(res.msg)
            this.$emit('queryRecords', this.query)
          }
        })
      });
    },
  },
  mounted() {
    this.token = getToken()
  }
}
</script>

<style scoped>

</style>
